<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<!-- #include virtual=/inc/action.header.inc.asp -->

<%
	If Request.Cookies("S_uid") = "" Then 
		response.write "Session Off!!"
		response.end
	End If 
			
	Set upload = server.CreateObject("DEXT.FileUpload")
	Set fs = CreateObject("Scripting.FileSystemObject")
	upload.DefaultPath = server.MapPath("/files/")
	upload.CodePage = 65001

	If IsObject(upload) = False Then
		response.write("DEXTUpload가 생성이 되지 않았습니다.")
		response.End
	End If

	bbsCd 	= upload("bbsCd")
	seq 		= upload("seq")
	flag 		= upload("flag")
	fileSeq = upload("fileSeq")
	
	files = upload("uFile").FileName  
	If files <> "" Then 
		files = upload("uFile").Save( ,false)
	End If 
	
	if fileSeq = "" then
		fileSeq = aFieldValue("SELECT ISNULL(MAX(fileSeq),0)+1 FROM tblFiles WHERE bbsCd='"  & bbsCd & "' AND bbsSeq=" & seq)		 
	end if 
	
	SQLTitle = "-- ■■■■ 파일 업로드 관리 저장 ■■■■"
	SQL = "exec spFiles '" & bbsCd & "', " & seq & ", '" & files & "', '" & flag & "', " & fileSeq
	
	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

'Response.write SQL
'Response.end
	DbCon.Execute SQL
	
	Response.write "DATA:{" 
	Response.wrtie """rsStatus"":""success"", "
	Response.write """seq"":""" &  seq & """, "
	Response.write """bbsCd"":""" & bbsCd & """, "
	Response.write """fileNm"":""" & files & """, "
	Response.write """fileSeq"":""" & fileSeq & """, "
	Response.write """flag"":""" & flag & """"
	Response.write "	}" & vbcrlf
	
%>